import React,{useState,useEffect} from "react";
import 'antd/dist/antd.min.css'

import { Table, Input, Button, Space } from 'antd';
import Highlighter from 'react-highlight-words';
import { SearchOutlined } from '@ant-design/icons';
import {render} from "@testing-library/react";


let VarTable = prop=>{

    return <Table columns={prop.columns} dataSource={prop.data} />

}

let Sli=(prop)=>{
    const [pressed,setPressed]=useState(true)
    useEffect(()=>{
        let dataSource = [
            {
                key: '1',
                name: '胡彦斌',
                age: 32,
                address: '西湖区湖底公园1号',
            },
            {
                key: '2',
                name: '胡彦祖',
                age: 42,
                address: '西湖区湖底公园1号',
            },
        ];

        const columns = [
            {
                title: '姓名',
                dataIndex: 'name',
                key: 'name',
            },
            {
                title: '年龄',
                dataIndex: 'age',
                key: 'age',
            },
            {
                title: '住址',
                dataIndex: 'address',
                key: 'address',
            },
        ];
        console.log("run");
        if(pressed===false){
            dataSource = [
                {
                    key: '1',
                    name: 'asd',
                    age: 32,
                    address: 'asf',
                },
                {
                    key: '2',
                    name: '胡彦祖',
                    age: 42,
                    address: '西湖区湖底公园1号',
                },
            ];
        }

        render(  pressed?<div id='123'><VarTable columns={columns} data={dataSource}/></div>:null)

    },[pressed])

    return<Button onClick={()=>{setPressed(!pressed);
        console.log(pressed);}}>aaaaaaaa</Button>
}

export default Sli